class RunHorse extends Thread	{
	final int MAX_DISTANCE = 600;
	int RaceDistance = 400;
	int CurrentDistance = 0;
	long RaceTime = 0L;

	// Constructors
	public RunHorse()	{
		super();
	}

	public RunHorse(String name)	{
		super(name);
	}

	public RunHorse(String name, int distance)	{
		super(name);
		RaceDistance = (distance < MAX_DISTANCE)? distance: MAX_DISTANCE;
	}

	public void run()	{
		long begin = 0L, end = 0L;

		begin = System.currentTimeMillis();
		while (CurrentDistance <= RaceDistance)	{
			CurrentDistance += Math.floor(Math.random() * 10);
			try	{
				sleep((long)(Math.random() * 200));
			} catch (InterruptedException e)	{}
		}
		end = System.currentTimeMillis();
		RaceTime = end - begin;
	}

	public int getCurrentDistance()	{
		return CurrentDistance;
	}

	public long getRaceTime()	{
		return RaceTime;
	}
}
